package session.stateless;

import entity.Product;
import java.util.List;
import javaclass.ProductType;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

@Stateless
public class ProductBean implements ProductBeanLocal {
    @PersistenceContext (unitName = "M10-IS3102-ejbPU")
    private EntityManager entityManager; 
    
    @Override
    public List<Product> getProductList() {
        Query q = entityManager.createQuery("SELECT c FROM Product c");
        return q.getResultList();
    }
    
     public Product findProduct(ProductType pType){
         return entityManager.find(Product.class, pType);
     }
}
